<template>
	<Table :Config="Config"></Table>
</template>
<script>
import tool from '@/utils/tool.js';

/*
columns属性说明:
	iskey       是否为主键
	title       标题
	dataIndex   字段
	width       宽度
	hidden      隐藏
	add         支持添加
	edit        支持编辑

type 说明:
	int/long    数字输入框
	string      文本框
	decimal     数字输入框
	date        日期
	datetime    日期时间
	time        时间
	checkbox    复选框 需要增加dict属性
	select      下拉框 需要增加dict属性
	radio       单选框 需要增加dict属性
	text        多行文本框


Config说明:
	getPageUrl  分页url
	getUrl      查询单条url
	addUrl      添加url
	editUrl     编辑url
	delUrl      删除url
	columns     行定义
	page        当前页码
	pageSize    每页数量
	navList     面包屑导航
*/

var dict_Disable = [
	{ value: 1, label: '禁用', color: 'gray' },
	{ value: 0, label: '正常', color: 'green' },
];
var dict_IsDel = [
	{ value: 0, label: '正常', color: 'green' },
	{ value: 1, label: '删除', color: 'red' },
];
var dict_DateList = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10'];

var columns = [
	{ title: '自增id', dataIndex: 'demo_id', iskey: true, width: 80, hidden: false, add: false, edit: false, type: 'int' },
	{ title: '添加时间', dataIndex: 'addtime', iskey: false, width: 150, hidden: false, add: false, edit: false, type: 'datetime' },
	{ title: '添加时间戳', dataIndex: 'addtime_stamp', iskey: false, width: 150, hidden: true, add: false, edit: false, type: 'long' },
	{ title: '添加用户', dataIndex: 'add_userid', iskey: false, width: 150, hidden: true, add: false, edit: false, type: 'int' },
	{ title: '修改时间', dataIndex: 'update_lasttime', iskey: false, width: 150, hidden: true, add: false, edit: false, type: 'datetime' },
	{ title: '修改时间戳', dataIndex: 'update_lasttime_stamp', iskey: false, width: 150, hidden: true, add: false, edit: false, type: 'long' },
	{ title: '最后修改人', dataIndex: 'last_userid', iskey: false, width: 150, hidden: true, add: false, edit: false, type: 'int' },
	{ title: '删除', dataIndex: 'isdel', iskey: false, width: 80, hidden: false, add: false, edit: false, type: 'select',
		customRender: function ({ text, record, index, column }) {
			 return tool.getDict(dict_Disable, text);
		}, },

	{ title: '名称', dataIndex: 'demo_name', iskey: false, width: 150, hidden: false, add: true, edit: true, type: 'string' },
	{ title: '名称', dataIndex: 'name', iskey: false, width: 150, hidden: true, add: false, edit: false, type: 'string' },
	{ title: '内容', dataIndex: 'content', iskey: false, width: 150, hidden: false, add: true, edit: true, type: 'string' },
	{ title: '到期时间', dataIndex: 'ext_time', iskey: false, width: 150, hidden: false, add: true, edit: true, type: 'datetime' },
	{ title: '价格', dataIndex: 'price', iskey: false, width: 100, hidden: false, add: true, edit: true, type: 'decimal' },
	{ title: '日期列表', dataIndex: 'date_list', iskey: false, width: 150, hidden: false, add: true, edit: true, type: 'checkbox', dict: dict_DateList },
	{
		title: '禁用',
		dataIndex: 'disable',
		iskey: false,
		width: 80,
		hidden: false,
		add: true,
		edit: true,
		type: 'select',
		dict: dict_Disable,
		customRender: function ({ text, record, index, column }) {
			 return tool.getDict(dict_Disable, text);
		},
	},
	{ title: '操作', dataIndex: 'action', hidden: false, add: false, edit: false /*fixed: 'right'*/ },
];

var columns_search = [
	{ title: '自增id', dataIndex: 'demo_id', type: 'int', filter: '=' },
	{ title: '添加时间', dataIndex: 'addtime', type: 'datetime', filter: '=' },
	// { title: '添加时间戳', dataIndex: 'addtime_stamp', type: 'long', filter: '=' },
	// { title: '添加用户', dataIndex: 'add_userid', type: 'int', filter: '=' },
	{ title: '修改时间', dataIndex: 'update_lasttime', type: 'datetime', filter: '=' },
	// { title: '修改时间戳', dataIndex: 'update_lasttime_stamp', type: 'long', filter: '=' },
	// { title: '最后修改人', dataIndex: 'last_userid', type: 'int', filter: '=' },
	{ title: '是否删除', dataIndex: 'isdel', type: 'select', filter: '=', dict: dict_IsDel },
	{ title: '名称', dataIndex: 'demo_name', type: 'string', filter: 'like' },
	{ title: '名称', dataIndex: 'name', type: 'string', filter: 'like' },
	{ title: '内容', dataIndex: 'content', type: 'string', filter: 'like' },
	{ title: '到期时间', dataIndex: 'ext_time', type: 'datetime', filter: '=' },
	{ title: '价格', dataIndex: 'price', type: 'decimal', filter: '=' },
	{ title: '日期列表', dataIndex: 'date_list', type: 'string', filter: 'like' },
	{ title: '禁用', dataIndex: 'disable', type: 'select', filter: '=', dict: dict_Disable },
];

export default {
	components: { tool },
	data() {
		return {
			Config: {
				getPageUrl: '/manage/ADemo/GetListByPage',
				getUrl: '/manage/ADemo/GetById',
				addUrl: '/manage/ADemo/Insert',
				editUrl: '/manage/ADemo/Update',
				delUrl: '/manage/ADemo/DeleteById',

				columns: columns,
				columns_search: columns_search,
				page: 1,
				pageSize: 15,

				navList: [
					{ to: '/', name: '首页' },
					{ to: '/System/user', name: '用户' },
					{ to: '', name: '平台管理' },
				],
				action: [{ name: '外部', funName: 'fun_Event1', type: false }],
			},
		};
	},
	methods: {
		fun_Event1(record) {
			var temp = record;
			this.$Message['success']({ background: true, duration: 1, content: '外部接口方法' });
		},
	},
};
</script>
